1. /* sdmfixpt.cpp by K.Tsuru */
  2. // function ID = 312, 313
  3. /*********************************************************
  4. SDouble and SDecimal classes
  5. It provides functions for fixed point mode.
  6. **********************************************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. /**********************************************************************
  11. It goes into the fixed point mode by giving the value of fixed exponent.
  12. In the summation of series it fixes the number of effective figures and
  13. decreases the number of figures to evaluate.
  14. It does not reduce the size by Reform() and does not change the exponent.
  15. The functions FixedPoint() and PointFree() must make a pair, and called by
  16. the same object.
  17. ***********************************************************************/
  18. int SDouble::fixedExp = 0;
  19. int SDouble::fixedPointMode = 0;
  20. static SNStack <int> fixedExpStack; // ver. 2.18
  21. // function ID = 312 DRADIX
  22. void SDouble::FixedPoint(int exp){
  23. if(!fixedExpStack.Elements()){
  24. fixedExpStack.Push(0);
  25. }
  26. if(CutDown() != DISABLE){
  27. CutDown(DISABLE);
  28. PushCD(PushedCD() | SD_PUSH);
  29. }
  30. if(fixedExp != exp){
  31. fixedExpStack.Push(fixedExp);
  32. PushCD(PushedCD() | CH_FE);
  33. fixedExp = exp;
  34. }
  35. fixedPointMode++;
  36. }
  37. // function ID = 313 DRADIX
  38. void SDouble::PointFree(){
  39. if( PushedCD() & SD_PUSH ){
  40. PushCD(PushedCD() & ~SD_PUSH);
  41. CutDown(POP);
  42. }
  43. if(PushedCD() & CH_FE){
  44. fixedExp = fixedExpStack.Pop();
  45. PushCD(PushedCD() & ~CH_FE);
  46. }
  47. int c = fixedPointMode/(FIXED_PT_MASK+1) + (fixedPointMode & FIXED_PT_MASK);
  48. fixedPointMode--;
  49. if(!c || (fixedPointMode < 0) ) SetError(SYNTAX_ERR,"PointFree", 313);
  50. }

sdmfixpt.cpp : last modifiled at 2016/09/04 14:21:40(1,690 bytes)
created at 2017/10/07 10:21:15
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).